When Mercury was formed, iron and other metals melted. These metals are very heavy. They sank to the center of the planet. As the metals sank, the lighter magma rose to the surface. The magma pushed through the cracks in the surface and formed smooth plains.
Then the planet cooled. As the core and mantle solidified, the planet shrank. This shrinkage and the pressure it produced closed up the volcanic cracks in the crust. The magma stopped flowing to the surface.